<?php
/**
 * @version $Id: extensionicons2.class.php 273 2007-12-06 18:27:26Z nik.elkuku $
 * repo $URL: http://joomla-codebase.googlecode.com/svn/trunk/extensionicons2/administrator/components/com_extensionicons2/extensionicons2.class.php $
 * Created on 14.04.2007
 * @package ExtensionIcons2
 * @author Nikolai Plath (elkuku)
 */

defined( '_JEXEC' ) or die( 'Restricted access' );

class ExtensionIcons2 extends JTable
{
  var $id = null;
  var $name = null;
  var $parent = null;
  var $parent_name = null;
  var $admin_menu_link = null;
  var $admin_menu_alt = null;
  var $linkoption = null;
  var $ordering = null;
  var $admin_menu_img = null;
  var $access_key = NULL;
  var $published = null;
// function ExtensionIcons( &$db )
// {
//	$db =& JTable::getInstance('extensionicons2', 'Table' );
// }
 	function __construct( &$_db )
	{
		parent::__construct( '#__extensionicons2', 'id', $_db );

//		jimport('joomla.utilities.date');
//		$now = new JDate();
//		$this->set( 'date', $now->toMySQL() );
	}

function loadConfig( &$config, $option )
{
#print_r($config);
  #global $mosConfig_absolute_path, $mosConfig_live_site, $database, $mosConfig_lang;
  if( file_exists( JPATH_ADMINISTRATOR.DS.'components'.DS.$config['APP_com_name'].DS.$config['APP_com_name'].'.config.php'))
  {
  require(JPATH_ADMINISTRATOR.DS.'components'.DS.$config['APP_com_name'].DS.$config['APP_com_name'].'.config.php');
	} else
	{
		echo '<h2 style="color: red">CONFIG NOT FOUND !</h2>';
		return FALSE;
	}
return TRUE;

#  include_once( $mosConfig_absolute_path . '/administrator/components/com_easycomments/includes/snoopy.class.php' );
//	if($ec_config['autoversioncheck'] == 1)
//	{
//		$s = new Snoopy();
//		$s->read_timeout = 90;
//		$s->referer = $mosConfig_live_site;		@$s->fetch('http://www.easy-joomla.org/components/com_versions/directinfo.php?catid=1');
//		$version = $s->results;
//		if($s->error || $s->status != 200){		
//	   		$version = "<span style='border-bottom: dotted 1px #b9b9b9; padding-right: 5px; padding-left: 5px;'><b>EasyComments ".$ec_config['version']."</b></span><br /><div style='margin-top: 5px;'><a href='http://www.easy-joomla.org/index.php?option=com_versions&catid=1&myVersion=".$ec_config['version']."' target='_blank'><img src='".$mosConfig_live_site."/administrator/components/com_easycomments/images/fail.gif' border='0' style='vertical-align: middle; padding-right: 5px;'/><span style='color: #e34639;'><b>"._EASYCOMMENTS_ADMIN_CONNECTION_FAILED."</b></span></a></div>";
//    	} else if($version == $ec_config['version']){
//			$version = "<span style='border-bottom: dotted 1px #b9b9b9; padding-right: 5px; padding-left: 5px;'><b>EasyComments ".$ec_config['version']."</b></span><br /><div style='margin-top: 5px;'><a href='http://www.easy-joomla.org/index.php?option=com_versions&catid=1&myVersion=".$ec_config['version']."' target='_blank'><img src='".$mosConfig_live_site."/administrator/components/com_easycomments/images/shield.gif' border='0' style='vertical-align: text-bottom; padding-right: 5px;'/> <span style='color: #e2ad43;'><b>"._EASYCOMMENTS_ADMIN_NO_UPDATES."</b></span></a></div>";
//    	} else {
// 	  		$version = "<span style='border-bottom: dotted 1px #b9b9b9; padding-right: 5px; padding-left: 5px;'><b>EasyComments ".$ec_config['version']."</b></span><br /><div style='margin-top: 5px;'><a href='http://www.easy-joomla.org/index.php?option=com_versions&catid=1&myVersion=".$ec_config['version']."' target='_blank'><img src='".$mosConfig_live_site."/administrator/components/com_easycomments/images/box.gif' border='0' style='vertical-align: text-bottom; padding-right: 5px;'/> <span style='color: #ce763a;'><b>"._EASYCOMMENTS_ADMIN_UPDATES_AVAILABLE."</b> EasyComments " . $version . "</span></a></div>";
//   		}
//	} else {	
//		$version = "<span style='border-bottom: dotted 1px #b9b9b9; padding-right: 5px; padding-left: 5px;'>
//		<b>EasyComments ".$ec_config['version']."</b>
//		</span><br /><div style='margin-top: 5px;'><a href='http://www.easy-joomla.org/index.php?option=com_versions&catid=1&myVersion=".$ec_config['version']."' target='_blank'><img src='".$mosConfig_live_site."/administrator/components/com_easycomments/images/box.gif' border='0' style='vertical-align: text-bottom; padding-right: 5px;'/><span style='color: #ce763a;'><b>"._EASYCOMMENTS_ADMIN_CHECK_FOR_NEW_UPDATES."</b></span></a></div>";
//	}
//$database->setQuery("UPDATE #__components SET name ='"._EASYCOMMENTS_INSTALL_MENU_SHOW."' WHERE admin_menu_link='option=com_easycomments&task=comments'");
//$database->query();
//$database->setQuery("UPDATE #__components SET name ='"._EASYCOMMENTS_INSTALL_MENU_SETTINGS."' WHERE admin_menu_link='option=com_easycomments&task=settings'");
//$database->query();
//$database->setQuery("UPDATE #__components SET name ='"._EASYCOMMENTS_INSTALL_MENU_ABOUT."' WHERE admin_menu_link='option=com_easycomments&task=about'");
//$database->query();
//$database->setQuery("UPDATE #__components SET name ='"._EASYCOMMENTS_INSTALL_MENU_MIGRATE."' WHERE admin_menu_link='option=com_easycomments&task=migrate'");
//$database->query();
//
//$seclistarray = explode (",", $ec_config['sectionlist']);
//$database -> setQuery("SELECT id,title FROM #__sections ORDER BY title ASC");
//$dbsectionlist = $database -> loadObjectList(); 
//
//$grouplistarray = explode (",", $ec_config['fe_grouplist']);
//$userslistarray = explode (",", $ec_config['fe_userslist']);
//$database -> setQuery("SELECT `id`, `name`, `username`, `usertype` FROM `#__users` ORDER BY `usertype` DESC, `name` ASC");
//$dbuserslist = $database -> loadObjectList(); 
//	$query = "SELECT `name`"
//	. "\n FROM #__core_acl_aro_groups"
//	. "\n WHERE name != 'ROOT'"
//	. "\n AND name != 'USERS'"
//	. "\n AND name != 'Public Frontend'"
//	. "\n AND name != 'Public Backend'"
//	. "\n ORDER BY `lft` DESC";
//	$database->setQuery( $query );
//	$usertypes = $database->loadObjectList();
//
// HTML_comment::showConfig( $dbsectionlist, $seclistarray, $dbuserslist, $userslistarray, $usertypes, $grouplistarray, $ec_config, $option, $version);
}

############################################################################
/**
 * Save the configuration
 */
function saveConfig( $config, $NAME, $option )//$option, $ec_config, $ec_mainmode, $ec_notify, $ec_emailcloak, $ec_frontendedit)
{
	echo '<hr />';
	echo $config['APP_com_name'].'<br />';
	print_r($config);
	echo '<hr />';
//  global $mosConfig_absolute_path;
//  $ec_config['mainmode'] = $ec_mainmode;
//  $ec_config['notify'] = $ec_notify;
//  $ec_config['emailcloak'] = $ec_emailcloak;
//  $ec_config['frontendedit'] = $ec_frontendedit;
$config['showtooltips']		= JRequest::getInt( 'showtooltips', 0 );
$config['logout']				= JRequest::getInt( 'logout', 0 );
echo $config['showtooltips'];
print_r($_REQUEST);
	echo '<hr />';
	echo $config['APP_com_name'].'<br />';
	print_r($config);
	echo '<hr />';
  $configfile = JPATH_ADMINISTRATOR.DS.'components'.DS.$config['APP_com_name'].DS.$config['APP_com_name'].'.config.php';
  @chmod ($configfile, 0766);
  $permission = is_writable($configfile);
  if (!$permission)
  {
		echo JText::_('not writeable');
		echo '<hr />'.$configfile.'<hr />';
#		mosRedirect("index2.php?option=$option&task=settings", _EASYCOMMENTS_ADMIN_NOTWRITABLE);
    return FALSE;
  }

//  $ec_config['sectionlist']   = implode(',',mosGetParam( $_REQUEST, 'ec_selections', null ));
//  $ec_config['fe_grouplist']   = implode(',',mosGetParam( $_REQUEST, 'ec_sel_groups', null ));
//  $ec_config['fe_userslist']   = implode(',',mosGetParam( $_REQUEST, 'ec_sel_users', null ));
//  $ec_config['\\\'show_readmore\\\''] = ( $ec_config['\\\'show_readmore\\\''] == 'on' ) ? 1 : 0;
	$s_string = "<?php\n";
	$s_string .= '$'.$NAME ." = ". "array(\n";
	foreach ($config as $name=>$value)
	{
		$name = stripslashes($name);
		$name = str_replace("'","",$name);
		$s_string .= "\"$name\" => \"$value\",\n";
	}
	$s_string .= ");\n";
	$s_string .= "?>";
  if ($fp = fopen("$configfile", "w"))
  {
    fputs($fp, $s_string);
    fclose ($fp);
  }
//  print_r($ec_config);
//  die();
 return TRUE;
mosRedirect("index2.php?option=$option&task=settings", _EASYCOMMENTS_ADMIN_SAVED_SETTINGS);
}




}// class














?>